<?php

/* Created by: Adam Malevski
 * Date: 2011-12-07
 * Class tests category.class.php
 */

require_once '../category.class.php';

$cat = new Category(1);

echo "<h2>Test with existed category</h1>";

// Tests get category ID
if ($cat->getId() == "1")
    echo "<p style='color:green;'>getId(): Test passed.</p>";
else
    echo "<p style='color:red;'>getId(): Test failed.</p>";

// Tests get category Name
if ($cat->getName() == "kategorija")
    echo "<p style='color:green;'>getName(): Test passed.</p>";
else
    echo "<p style='color:red;'>getName(): Test failed.</p>";

// Tests set category Name
if ($cat->setName("kategorija"))
    echo "<p style='color:green;'>setName(): Test passed.</p>";
else
    echo "<p style='color:red;'>setName(): Test failed.</p>";

    
// Tests updated get category Name
if ($cat->getName() == "kategorija")
    echo "<p style='color:green;'>getName(): Test passed.</p>";
else
    echo "<p style='color:red;'>getName(): Test failed.</p>";


echo "<h2>Test with create category</h1>";

$ncat = new Category(NULL, "kat");
// Tests get category ID
if ($ncat->getId() == "5")
    echo "<p style='color:green;'>getId(): Test passed.</p>";
else
    echo "<p style='color:red;'>getId(): Test failed.</p>";

// Tests get category Name
if ($ncat->getName() == "kat")
    echo "<p style='color:green;'>getName(): Test passed.</p>";
else
    echo "<p style='color:red;'>getName(): Test failed.</p>";

?>
